import json

from bottle import Bottle, request, response ,template ,static_file
# from core.shadowDataPreProcess.dataCombine import process_json_files
from schema.decorator.validation import validate_post_params, is_valid_unix_timestamp

combineApp = Bottle()

@combineApp.route('/signal_combine_test', method=['GET', 'POST'])
def combine_bag():
    if request.method == 'GET':
        input_directory = "/common/vis_demo/input"
        output_directory = "/common/vis_demo/output"
        #调用combine程序
        process_json_files(input_directory,output_directory)
        # TODO
        return json.dumps({'message': 'This is a JSON response! GET'})
    elif request.method == 'POST':
        # TODO
        data = request.json
        return json.dumps({'message': 'This is a JSON response! POST'})

@combineApp.route('/signal_combine', method=['GET', 'POST'])
@validate_post_params(required_params=['timestamp'], param_validators={'timestamp': is_valid_unix_timestamp})
def combine_bag():
    if request.method == 'GET':
        # TODO
        return json.dumps({'message': 'This is a JSON response!'})
    elif request.method == 'POST':
        # TODO
        data = request.json
        return json.dumps({'message': 'This is a JSON response!'})

@combineApp.route('/batch_combine', method=['GET','POST'])
#@validate_post_params(required_params=['timestamp'], param_validators={'timestamp': is_valid_unix_timestamp})
def combine_bags():
    if request.method == 'GET':
        # TODO
        return json.dumps({'message': 'This is a JSON response!'})
    elif request.method == 'POST':
        # TODO
        data = request.json
        return json.dumps({'message': 'This is a JSON response!'})